<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增油品信息</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: url('/images/2.jpg') no-repeat center center fixed;
            background-size: cover;
            font-family: "微软雅黑", sans-serif;
        }

        /* 主体内容区域样式 */
        .main-content {
            margin-left: 200px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.5);
            min-height: calc(100vh - 50px);
        }

        .breadcrumb {
            margin-bottom: 20px;
            color: #999;
        }

        .breadcrumb a {
            color: #000;
            text-decoration: none;
        }

        .breadcrumb a:hover {
            text-decoration: underline;
        }

        .breadcrumb .current-page {
            color: #000;
        }

        /* 表单样式 */
        .form-container {
            background-color: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 5px;
            max-width: 600px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }

        .form-group input {
            width: 100%;
            padding: 8px 10px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        .error-msg {
            color: #d9534f;
            margin-bottom: 15px;
            padding: 10px;
            background-color: rgba(221, 17, 68, 0.1);
            border-radius: 3px;
        }

        .btn-group {
            margin-top: 20px;
        }

        .btn {
            padding: 8px 15px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            margin-right: 10px;
            color: #fff;
        }

        .btn-submit {
            background-color: #5cb85c;
        }

        .btn-cancel {
            background-color: #777;
        }

        /* 公共组件样式继承 */
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #9b2222;
            color: #fff;
            padding: 10px 20px;
        }

        .sidebar {
            width: 200px;
            background-color: #fff;
            float: left;
            height: calc(100vh - 50px);
            padding-top: 20px;
            position: relative;
            border-right: 1px solid #eee;
        }

        .sidebar ul { list-style: none; }

        .sidebar li {
            padding: 12px 20px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .sidebar li:hover { background-color: #ddd; }

        .sidebar li a {
            text-decoration: none;
            color: inherit;
            display: block;
        }

        .sidebar li.active {
            background-color: #ddd;
            font-weight: bold;
        }
    </style>
</head>
<body>
<!-- 引入顶部导航栏 -->
<div th:replace="~{common/common::topbar}"></div>

<!-- 引入侧边栏 -->
<div th:replace="~{common/common::sidebar}"></div>

<!-- 主体内容区域 -->
<div class="main-content">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
        <a href="/login.html">系统首页</a> >
        <a href="/oil_info/list">油品信息管理</a> >
        <span class="current-page">新增油品</span>
    </div>

    <!-- 错误提示 -->
    <div th:if="${not #strings.isEmpty(errorMsg)}" class="error-msg">
        [[${errorMsg}]]
    </div>

    <!-- 表单容器 -->
    <div class="form-container">
        <h3>新增油品信息</h3>
        <form th:action="@{/oil_info/save}" method="post">
            <div class="form-group">
                <label for="oilName">油品名称</label>
                <input type="text" id="oilName" name="oilName" placeholder="例如：92号汽油" required>
            </div>

            <div class="form-group">
                <label for="stock">库存量</label>
                <input type="number" id="stock" name="stock" min="0" placeholder="请输入库存量" required>
            </div>

            <div class="form-group">
                <label for="unitPrice">销售单价(元)</label>
                <input type="number" id="unitPrice" name="unitPrice" step="0.01" min="0.01" placeholder="请输入单价" required>
            </div>

            <div class="form-group">
                <label for="supplier">供应商名称</label>
                <input type="text" id="supplier" name="supplier" placeholder="例如：中石油" required>
            </div>

            <div class="btn-group">
                <button type="submit" class="btn btn-submit">提交</button>
                <a href="/oil_info/list" class="btn btn-cancel">取消</a>
            </div>
        </form>
    </div>
</div>

<script>
    // 设置侧边栏激活状态
    document.addEventListener('DOMContentLoaded', function() {
        const sidebarItems = document.querySelectorAll('.sidebar li a');
        sidebarItems.forEach(item => {
            if (item.getAttribute('href') === '/oil_info/list') {
                item.parentElement.classList.add('active');
            }
        });
    });
</script>
</body>
</html>